app.controller('logController', ['$scope', 'httpWrapService', '$state', '$stateParams','uiGridConstants','GridFactory',
        function($scope, httpWrapService, $state, $stateParams,uiGridConstants, GridFactory) {

    var columnDefs = [
        {name: "用户", field: "userId",maxWidth: 120,
            filter : {
                type :  uiGridConstants.filter.CONTAINS
            }
        },
        {
            name: "时间", field: "time",maxWidth: 140,
            filterHeaderTemplate: '<div class="ui-grid-filter-container" ng-repeat="colFilter in col.filters" ng-controller="DatepickerDemoCtrl"' +
            ' ng-class="{\'ui-grid-filter-cancel-button-hidden\' : colFilter.disableCancelFilterButton === true }">' +
            '<div ng-click="open($event)">' +
            '<input type="text" readonly="readonly" class="ui-grid-filter-input input-group" ng-model="colFilter.term" ng-attr-placeholder="{{colFilter.placeholder || \'\'}}" uib-datepicker-popup="{{format}}"  placeholder="出生日期" is-open="status.opened" datepicker-options="dateOptions" datepicker-append-to-body="true" ng-required="true" close-text="关闭" clear-text="重置" current-text="今天" />' +
            '<div class="ui-grid-filter-button" ng-click="colFilter.term = null; $event.stopPropagation();" ng-if="!colFilter.disableCancelFilterButton">' +
            '<i class="ui-grid-icon-cancel" ng-show="colFilter.term !== undefined && colFilter.term !== null && colFilter.term !== \'\'">&nbsp;' +
            '</i>' +
            '</div>' +
            '</div>' +
            '</div>',
            filters: [
                {
                    type: uiGridConstants.filter.GREATER_THAN_OR_EQUAL
                },
                {
                    type: uiGridConstants.filter.LESS_THAN_OR_EQUAL,
                    format : 'YYYY-MM-DD 23:59:59'
                }
            ]
        },
        {name: "IP", field: "ip",maxWidth: 120} ,
        //{name: "大模块", field: "bigModule",
        //    cellFilter: 'dictionaryFiter : "bigModuleLogType"',
        //    filter : {
        //        noTerm: true,
        //        type: uiGridConstants.filter.SELECT,
        //        selectOptions : $scope.dictionary.bigModuleLogType
        //    }
        //} ,
        {name: "小模块", field: "littleModule",
            maxWidth: 120,
            cellFilter: 'dictionaryFiter : "littleModuleLogType"',
            filter : {
                noTerm: true,
                type: uiGridConstants.filter.SELECT,
                selectOptions : $scope.dictionary.littleModuleLogType
            }
        } ,
        {name: "操作类型", field: "type",
            maxWidth: 90,
            cellFilter: 'dictionaryFiter : "logOperationType"',
            filter : {
                noTerm: true,
                type: uiGridConstants.filter.SELECT,
                selectOptions : $scope.dictionary.logOperationType
            }
        },
        {name: "是否成功", field: "isSuccess",
            maxWidth: 90,
            cellFilter: 'dictionaryFiter : "yesOrNo"',
            filter : {
                noTerm: true,
                type: uiGridConstants.filter.SELECT,
                selectOptions : $scope.dictionary.yesOrNo
            }} ,
        {name: "备注", field: "msg",
            filter : {
                type :  uiGridConstants.filter.CONTAINS
            }}
    ];

    $scope.Grid = GridFactory.newInstance({
        url : 'system/log/list.do',
        columnDefs : columnDefs,
        gridOptions : {
            useExternalSorting : true,
            useExternalPagination : true,
            useExternalFiltering : true
        }
    });
    $scope.Grid.load();

}]);